import os
import argparse

# 设置 Hugging Face 镜像（可选）
# import sys
# sys.path.insert( 0 , os.path.abspath( __file__ ) )
import util_for_huggingface

from huggingface_hub import snapshot_download

def download_model(repo_id, allow,ignore):
    snapshot_download(repo_id=repo_id,
                      allow_patterns=allow,
                      ignore_patterns=ignore,
                      )

if __name__ == "__main__":
    # 定义命令行参数
    parser = argparse.ArgumentParser()
    parser.add_argument('-n',"--name", type=str, required=True, help="Hugging Face 模型名称（如 'LiheYoung/depth-anything-large-hf'）")
    parser.add_argument('-a',"--allow", nargs='+',default=None, required=False, help="allow patterns")
    parser.add_argument('-i',"--ignore", nargs='+',default=None, required=False, help="ignore patterns")
    # parser.add_argument("--save", type=str, required=True, help="本地保存路径（如 './depth-anything-large-hf'）")
    args = parser.parse_args()

    print(args.name,args.allow,args.ignore)
    # 调用下载函数
    download_model(args.name,args.allow,args.ignore)  # allow 如果赋值 [],则不会下载任何内容，赋值None比较合理
    # download_model('stabilityai/sd-vae-ft-mse')
    # python huggingface_download.py -n levihsu/OOTDiffusion -i checkpoints/ootd/* checkpoints/ootd/**